package jvm;

public class JvmTest {
	public static void main(String[] args) {
		//查看GC信息
		//Runtime.getRuntime().maxMemory() jvm试图使用的最大内存
		//Runtime.getRuntime().totalMemory() 当前jvm使用内存
		System.out.println("maxMemory:"+(double)(Runtime.getRuntime().maxMemory()/(1024*1024)));
		System.out.println("freeMemory:"+(double)(Runtime.getRuntime().freeMemory()/(1024*1024)));
		System.out.println("totalMemory:"+(double)(Runtime.getRuntime().totalMemory()/(1024*1024)));

		byte[] b1 = new byte[1*1024*1024];
		System.out.println("分配了1M");

		System.out.println("maxMemory:"+(double)(Runtime.getRuntime().maxMemory()/(1024*1024)));
		System.out.println("freeMemory:"+(double)(Runtime.getRuntime().freeMemory()/(1024*1024)));
		System.out.println("totalMemory:"+(double)(Runtime.getRuntime().totalMemory()/(1024*1024)));

		byte[] b2 = new byte[4*1024*1024];
		System.out.println("分配了4M");
		System.out.println("maxMemory:"+(double)(Runtime.getRuntime().maxMemory()/(1024*1024)));
		System.out.println("freeMemory:"+(double)(Runtime.getRuntime().freeMemory()/(1024*1024)));
		System.out.println("totalMemory:"+(double)(Runtime.getRuntime().totalMemory()/(1024*1024)));
	}
}
